#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/12/6 8:46
# @Author  : FuKai ZHANG
# @File    : setting.py
# @Description :路径统一
import os.path

from typing import Text


def rootpath():
    """获取当前项目的绝对路径"""
    path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    return path


def ensure_path_sep(path: Text) -> Text:
    """
    兼容 Windows 和 Linux 不同环境的路径处理
    :param path: 输入路径
    :return: 修正后的路径
    """
    # 标准化路径分隔符
    if "/" in path or "\\" in path:
        path = os.path.normpath(path)

    # 拼接根路径和子路径
    full_path = os.path.join(rootpath(), path.lstrip(os.sep))

    return full_path

